package com.hc.factory;

import java.io.IOException;
import java.util.Properties;

public class BeanFactory {
    private Properties properties = new Properties();

    public BeanFactory(String config) {
        try {
            properties.load(BeanFactory.class.getResourceAsStream(config));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public Object getBean(String beanClass){
        String className = properties.getProperty(beanClass);
        try {
            Class<?> aClass = Class.forName(className);
            return aClass.newInstance();
        } catch (Exception e) {
            return null;
        }
    }
}
